<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");

$AUDIOID = $_REQUEST['AUDIOID'];
if (is_numeric($AUDIOID))
{
	$query="SELECT allowdownloads,audio_name FROM audios WHERE public='1' AND active='1' AND AUDIOID='".mysql_real_escape_string($AUDIOID)."' limit 1";
	$executequery = $conn->Execute($query);
	$allowdownloads = $executequery->fields[allowdownloads];
	$audio_name = $executequery->fields[audio_name];
}
else
{
	$error = "$lang[541]";
}

if ($allowdownloads == "1")
{

	if ($config['who_can_download'] == "1")
	{
		if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
		{
			header("location:$config[audiourl]/$audio_name");
			exit;
		}
		else
		{
			header("location:$config[baseurl]/login.php");
			exit;
		}
	}
	else
	{
		header("location:$config[audiourl]/$audio_name");
		exit;
	}

}
else
{
	$error = "$lang[542]";
}

if ($error != "")
{
	STemplate::assign('error',$error);
	$pagetitle = "$lang[44]";
	STemplate::assign('pagetitle',$pagetitle);

	//TEMPLATES BEGIN
	STemplate::display('header.tpl');
	STemplate::display('empty.tpl');
	STemplate::display('footer.tpl');
	//TEMPLATES END
}
?>